Fix wrongly identified circular dependencies#2113
Closed
harrysarson wants to merge 4 commits intoapache:masterfrom
Closed
Fix wrongly identified circular dependencies#2113harrysarson wants to merge 4 commits intoapache:masterfrom
harrysarson wants to merge 4 commits intoapache:masterfrom
Conversation
This commit adds an additional level of nesting to the override-self
buildstream test project by a new subproject and moving the
self-junction into the subproject.
Both the `link.bst` and the `nested-link.bst` elements point to the
subproject's `target.bst` element but `nested-link.bst` does so via the
self-junction, hence the "nesting".
Running `bst show --deps none nested-link.bst` in the directory
`tests/format/junctions/override-self` gives the following output:
```
20:17:48 --:--:-- main:core activity START Loading elements
20:17:48 00:00:00 main:core activity FAILURE Loading elements
project.conf [line 6 column 2]: Circular reference while searching for 'subproject.bst:self-junction.bst'
Already searching for 'subproject.bst:self-junction.bst' at: nested-link.bst [line 4 column 10]
```
This commit load ensures the toplevel project is always loaded, even when addressing subproject elements via link. Commit cff58ec added a call to `Project.ensure_fully_loaded` to ensure the toplevel project is resolved first when addressing subproject elements on the command line. The commit assumes that whenever subproject elements are referenced on the command line, `Loader.get_loader` is called with `provenance_node == None`. However, if a link element that points to a subproject element is referenced on the command line then `get_loader` will be called with `provenance_node` referencing the link element. This means that `get_loader` skips the call to `ensure_fully_loaded` causing buildstream to crash. This commit fixes the crash by moving the call to `ensure_fully_loaded` up the call chain into `Loader.load` where we know that the element is addressed from the command line.
This commit moves subproject into a new intermediate project and the
subproject.bst junction element is replaced by a link element. Including
a file from a nested junction via a link element in the top level
project.conf file tests more code paths in the loader.
This change shows a bug in the loader, running `bst show --deps none
target.bst` in the directory `tests/format/junctions/include-complex`
gives the following output:
```
20:02:32 --:--:-- main:core activity START Loading elements
20:02:32 00:00:00 main:core activity FAILURE Loading elements
intermediate-project.bst:project.conf [line 5 column 2]: Circular reference while searching for 'subproject.bst'
Already searching for 'subproject.bst' at: subproject.bst [line 4 column 10]
```
juergbi
reviewed
Apr 24, 2026
| "target", | ||
| ["target.bst", "subproject.bst:target.bst"], | ||
| ["target.bst", "subproject.bst:target.bst", "intermediate-project.bst:subproject.bst:target.bst"], | ||
| ids=["toplevel-target", "subproject-target"], |
Contributor
There was a problem hiding this comment.
New ID is missing, blocking pytest.
Suggested change
| ids=["toplevel-target", "subproject-target"], | |
| ids=["toplevel-target", "subproject-target", "nested-link-target"], |
| # Other callers of `_parse_name` or `_load_file` that reference | ||
| # files through a project element or otherwise do not need to | ||
| # ensure fully loaded. | ||
| self.project.ensure_fully_loaded() |
Contributor
There was a problem hiding this comment.
Unfortunately, this loading is too eager, resulting in a regression of #1686.
I'm trying to find an alternative fix that avoids that regression.
Contributor
There was a problem hiding this comment.
I've opened #2114, which fixes this issue in a different way. It includes and passes your tests from this branch (adjusted to keep the previous tests without changes).
Contributor
|
Closing this as #2114 has been merged to address the issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2037